var Ex=function (o){for(var k in o)this[k]=o[k];return this}
var UI=function (id){return document.getElementById(id)}
var UIs=function (tag){return Ex.call([],this.getElementsByTagName(tag))}
var Each=function (a,fn){for(var i=0;i<a.length;i++)fn.call(a[i],i,a)}
var dhooo=function (ini){
this.bind(ini,this);
this.autoIndex=0;
};
Ex.call(dhooo.prototype,{
bind:function (ini,me){
var dir=ini.dir=='top'?'scrollTop':'scrollLeft',pan=UI(ini.contentID);
var start=function (o){
Each(ini.btns,function(){this.className=''});
o.className=ini.className;
me.autoIndex=o.index;
me.begin(o.index,pan,ini.len,dir);
};
pan.onmouseover=function (){me.stop=true};
Each(ini.btns,function (i){
this.index=i;
this.onmouseover=function (){me.stop=true;start(this)};
pan.onmouseout=this.onmouseout=function(){me.stop=false}
});
var auto=function(){
if(!me.stop){
me.autoIndex=me.autoIndex==bannercount?0:++me.autoIndex;
start(ini.btns[me.autoIndex]);
}
};
if(ini.auto)this.autoPlay=window.setInterval(auto,5000);
}
,begin:function (i,o,len,dir){
(function (me){
clearInterval(me.only);
            me.only=setInterval(function (){
                var diff=(i*len-o[dir])*0.1;
                o[dir]+=Math[diff>0?'ceil':'floor'](diff);
                if(diff==0)clearInterval(me.only);
            },10)
        })(this)
}
})


if(!isIE_8()){

    if(isIE_c()){
    new dhooo({
    btns:UIs.call(UI('myTab_btns2'),'LI')
    ,className:'nonce'
    ,contentID:'main2'
    ,len:202
    ,dir:'top'
    ,auto:true
    });
    }else{
        new dhooo({
            btns:UIs.call(UI('myTab_btns2'),'LI')
            ,className:'nonce'
            ,contentID:'main2'
            ,len:198
            ,dir:'top'
            ,auto:true
            });
    }
}else{

    new dhooo({
    btns:UIs.call(UI('myTab_btns2'),'LI')
    ,className:'nonce'
    ,contentID:'main2'
    ,len:198
    ,dir:'top'
    ,auto:true
    });
}


function $(id)
{
    return document.getElementById(id);
}
        var productDiv=new Array();
productDiv=[["showproduct1,imgproduct1","productlist1"],["showproduct2,imgproduct2","productlist2"],["showproduct3,imgproduct3","productlist3"],["showproduct4,imgproduct4","productlist4"]];

var playnum=1;

function showproductdiv(id){
if(id==0){id=playnum;}
    for(i=1;i<=5;i++){
 
            if(i==id){
            $("showproduct"+id).style.display="block";
            $("imgproduct"+id).style.display="none";
            $("__I"+id).style.display="block";
            }
            else{
            $("showproduct"+i).style.display="none";
            $("imgproduct"+i).style.display="block";
            $("__I"+i).style.display="none";
            }



    }

    if(playnum==5){playnum=1}else{playnum++}

}
var myplay;
function ProductDivPlay(id){
    if(id==""){id=0}else{playnum=id}

    myplay=setInterval("showproductdiv(0)",8000);
}

function ProductDivStop(){

    clearInterval(myplay);
}

ProductDivPlay(0);

function showhidediv(){
    for(i=0;i<arguments.length;i++){
        if(i==0){
            if(arguments[i]=="service"){$(arguments[i]).className="h2_other nonce"}else{$(arguments[i]).className="nonce"};
        }
        if(i==1){
            $(arguments[i]).style.display="";
        }
        if(i==2){
            if(arguments[i]=="service"){$(arguments[i]).className="h2_other"}else{$(arguments[i]).className=""};
        }
        if(i==3){
             if(arguments[i]=="service"){$(arguments[i]).className="h2_other"}else{$(arguments[i]).className=""};
        }
        if(i==4){
            $(arguments[i]).style.display="none";
        }
        if(i==5){
            $(arguments[i]).style.display="none";
        }
    }
}

function showhidedivbhbang(shownum,idname){

    for(i=1;i<4;i++){
        if(i==shownum){            
            $(idname+i).style.display="";
            if(i==1)
                $(idname+"title"+i).className="other nonce";
            else
                $(idname+"title"+i).className="nonce";

        }else{
            $(idname+i).style.display="none";
            if(i!=1)
            $(idname+"title"+i).className="";
            else
            $(idname+"title"+i).className="other";
        }
    }
}




//��ʱ����
var the_s=new Array();



function view_time(the_s_index,objid){

    if(the_s[the_s_index]>=0){
        var the_D=Math.floor((the_s[the_s_index]/3600)/24)
        var the_H=Math.floor((the_s[the_s_index]-the_D*24*3600)/3600);
        var the_M=Math.floor((the_s[the_s_index]-the_D*24*3600-the_H*3600)/60);
        var the_S=(the_s[the_s_index]-the_H*3600)%60;
        html = "��ʣ ";
        //if(the_D!=0) html += the_D+"��";
        if(the_D!=0 || the_H!=0) html += '<span class="hour">'+(the_H+(the_D*24))+"</span>Сʱ";
        if(the_D!=0 || the_H!=0 || the_M!=0) html += '<span class="minute">'+the_M+"</span>��";
        html += '<span class="second">'+the_S+"</span>��";
        $(objid).innerHTML = html;
        the_s[the_s_index]--;
    }else{
        $(objid).innerHTML = "�ѽ���";

    }
}



function ScrollText(content,btnPrevious,btnNext,autoStart)
{
    this.Delay = 10;
    this.LineHeight = 25;
	this.Amount = 1;
	this.Direction = "up";
    this.Timeout = 4000;
    
    this.ScrollContent = this.gid(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
    //this.ScrollContent.scrollTop = 0;

    
    
    if(btnNext)
    {
        this.NextButton = this.gid(btnNext);
        this.NextButton.onclick = this.GetFunction(this,"Next");
        this.NextButton.onmouseover = this.GetFunction(this,"Stop");
        this.NextButton.onmouseout = this.GetFunction(this,"Start");
    }
    if(btnPrevious)
    {
        this.PreviousButton = this.gid(btnPrevious);
        this.PreviousButton.onclick = this.GetFunction(this,"Previous");
        this.PreviousButton.onmouseover = this.GetFunction(this,"Stop");
        this.PreviousButton.onmouseout = this.GetFunction(this,"Start");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this,"Stop");
    this.ScrollContent.onmouseout = this.GetFunction(this,"Start");
    if(autoStart)
    {
        this.Start();
    }
}

ScrollText.prototype.gid = function(element)
{
    return document.getElementById(element);
}

ScrollText.prototype.Previous = function()
{
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("up");
}

ScrollText.prototype.Next = function()
{
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("down");
}

ScrollText.prototype.Start = function()
{
    clearTimeout(this.AutoScrollTimer);
    this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
}

ScrollText.prototype.Stop = function()
{
    clearTimeout(this.ScrollTimer);
    clearTimeout(this.AutoScrollTimer);
}

ScrollText.prototype.AutoScroll = function()
{
    if(this.Direction == "up")
    {
        if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
            clearTimeout(this.AutoScrollTimer);
            this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
            return;
        }
        this.ScrollContent.scrollTop += this.Amount;
    }
    else
    {
        if(parseInt(this.ScrollContent.scrollTop) <= 0)
        {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
    {
        this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Delay);
    }
    else
    {        
        this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
    }
}

ScrollText.prototype.Scroll = function(direction)
{
    if(direction=="up")
    {
        if(this.ScrollContent.scrollTop == 0)
        {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    else
    {
        this.ScrollContent.scrollTop += this.Amount;
    }
    if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
        }
    if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
    {
        this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Delay);
    }
}

ScrollText.prototype.GetFunction = function(variable,method,param)
{
    return function()
    {
        variable[method](param);
    }
}
//ff����
function isIE_c(){
    if(window.navigator.userAgent.toLowerCase().indexOf("msie 8.0")>1)
        return false;
   return window.navigator.userAgent.toLowerCase().indexOf("msie")>=1?true:false;
}

function isIE_8(){
    if(window.navigator.userAgent.toLowerCase().indexOf("msie 8.0")>1)
        return true;
    else
        return false;
}

function dq_discount(scale,discount)
{
    var str="<p style='margin-top:-"+(scale*40)+"px;margin-left:-140px;' align=right>";
str+="<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 WIDTH="+46*scale+" HEIGHT="+46*scale+"><param name='FlashVars' value='discount="+discount+"'><PARAM NAME=movie VALUE=http://img3.dangdang.com/08dushujie/dqnew.swf> <PARAM NAME=menu VALUE=false>  <PARAM NAME=wmode VALUE=transparent><embed src=http://img3.dangdang.com/07dq/dq.swf width="+46*scale+" height="+46*scale+" type=application/x-shockwave-flash wmode=transparent FlashVars='discount="+discount+"'/></OBJECT>"
str+="</p>";

if(discount<67)
   document.write(str);
}
//ͼƬ�����б� mengjia 070927
var Speed_1 = 10; //�ٶ�(����)
var Space_1 = 10; //ÿ���ƶ�(px)
var PageWidth_1 = 151 * 1; //��ҳ���
var interval_1 = 7000; //��ҳ���
var fill_1 = 0; //������λ
var MoveLock_1 = false;
var MoveTimeObj_1;
var MoveWay_1="right";
var Comp_1 = 0;
var AutoPlayObj_1=null;
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
function AutoPlay_1(){clearInterval(AutoPlayObj_1);AutoPlayObj_1=setInterval('ISL_GoDown_1();ISL_StopDown_1();',interval_1)}
function ISL_GoUp_1(){if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="left";MoveTimeObj_1=setInterval('ISL_ScrUp_1();',Speed_1);}
function ISL_StopUp_1(){if(MoveWay_1 == "right"){return};clearInterval(MoveTimeObj_1);if((GetObj('ISL_Cont_1').scrollLeft-fill_1)%PageWidth_1!=0){Comp_1=fill_1-(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1);CompScr_1()}else{MoveLock_1=false}
AutoPlay_1()}
function ISL_ScrUp_1(){if(GetObj('ISL_Cont_1').scrollLeft<=0){GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft+GetObj('List1_1').offsetWidth}
GetObj('ISL_Cont_1').scrollLeft-=Space_1}
function ISL_GoDown_1(){clearInterval(MoveTimeObj_1);if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="right";ISL_ScrDown_1();MoveTimeObj_1=setInterval('ISL_ScrDown_1()',Speed_1)}
function ISL_StopDown_1(){if(MoveWay_1 == "left"){return};clearInterval(MoveTimeObj_1);if(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1-(fill_1>=0?fill_1:fill_1+1)!=0){Comp_1=PageWidth_1-GetObj('ISL_Cont_1').scrollLeft%PageWidth_1+fill_1;CompScr_1()}else{MoveLock_1=false}
AutoPlay_1()}
function ISL_ScrDown_1(){if(GetObj('ISL_Cont_1').scrollLeft>=GetObj('List1_1').scrollWidth){GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft-GetObj('List1_1').scrollWidth}
GetObj('ISL_Cont_1').scrollLeft+=Space_1}
function CompScr_1(){if(Comp_1==0){MoveLock_1=false;return}
var num,TempSpeed=Speed_1,TempSpace=Space_1;if(Math.abs(Comp_1)<PageWidth_1/2){TempSpace=Math.round(Math.abs(Comp_1/Space_1));if(TempSpace<1){TempSpace=1}}
if(Comp_1<0){if(Comp_1<-TempSpace){Comp_1+=TempSpace;num=TempSpace}else{num=-Comp_1;Comp_1=0}
GetObj('ISL_Cont_1').scrollLeft-=num;setTimeout('CompScr_1()',TempSpeed)}else{if(Comp_1>TempSpace){Comp_1-=TempSpace;num=TempSpace}else{num=Comp_1;Comp_1=0}
GetObj('ISL_Cont_1').scrollLeft+=num;setTimeout('CompScr_1()',TempSpeed)}}
function picrun_ini(){
GetObj("List2_1").innerHTML=GetObj("List1_1").innerHTML;
GetObj('ISL_Cont_1').scrollLeft=fill_1>=0?fill_1:GetObj('List1_1').scrollWidth-Math.abs(fill_1);
GetObj("ISL_Cont_1").onmouseover=function(){clearInterval(AutoPlayObj_1)}
GetObj("ISL_Cont_1").onmouseout=function(){AutoPlay_1()}
AutoPlay_1();
}

picrun_ini();
//��Ʒչʾ����ͼƬ����

function promo_icon(url,discount){

    var str="<span class='labelpanel'>";
     str+="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='50'  height='50'>";
     str+="<param name='movie' value='"+url+"'/>";
     str+="<param name='quality' value='high'/>";     
     str+="<param name='FlashVars' value='discount=" + discount + "'>";
     str+="<param name='wmode' value='transparent' />";
     str+="<embed src='"+url+"' FlashVars='discount=" + discount + "' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='50'  height='50'></embed>";
     str+="</object></span>";
    document.write(str);
}
function dq_discount(scale,discount)
{
    var str="<p style='margin-top:-"+(scale*40)+"px;margin-left:-140px;' align=right>";
str+="<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 WIDTH="+46*scale+" HEIGHT="+46*scale+"><param name='FlashVars' value='discount="+discount+"'><PARAM NAME=movie VALUE=http://img3.dangdang.com/08dushujie/dqnew.swf> <PARAM NAME=menu VALUE=false>  <PARAM NAME=wmode VALUE=transparent><embed src=http://img3.dangdang.com/07dq/dq.swf width="+46*scale+" height="+46*scale+" type=application/x-shockwave-flash wmode=transparent FlashVars='discount="+discount+"'/></OBJECT>"
str+="</p>";

if(discount<67)
   document.write(str);
}

var intTimeStep=10;//������ʾ�ٶ�ֵ�� -�ٶ���
var isIe=(window.ActiveXObject)?true:false;
var intAlphaStep=(isIe)?10:0.1;//ֵ���ٶȿ�
var intHeiStep = 20;
var curSObj=null;
var curOpacity=null;
var imgObj=null ;
var banner_show_num;
var divheight = 520 ;


function d_getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return '';
}
function d_setCookie(name, value, expires, path, domain, secure)
{

var t_dq_now = new Date();
var t_dq_year = t_dq_now.getFullYear();
var t_dq_month = t_dq_now.getMonth()+1;
var t_dq_date = t_dq_now.getDate();
var cookietimeout=new Date(t_dq_year+"/"+t_dq_month+"/"+t_dq_date+" 23:59:59");


var liveDate = new Date();
//expires = liveDate.setTime(liveDate.getTime() + expires*60*1000);//����
expires = new Date((new Date()).getTime() + expires * 60000);//������
document.cookie = name + "=" + escape (value) +"; expires=" + cookietimeout.toGMTString() +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}



function default_trim(str){return str.replace(/(\s*$)|(^\s*)/g, '');};

function startObjVisible(objId)
{

    var shows = d_getCookies("showbanner");
    if(shows!=""&&shows!="NaN"){
        banner_show_num= shows;
    }else{
        banner_show_num=1;
    }
    imgObj=document.getElementById('top_ads_pic');
    var bigimg_path=document.getElementById('bigpic_path').value ;
    imgObj.src=bigimg_path ;
    if(banner_show_num<2){
        curSObj=document.getElementById(objId);
        setObjState();
        setObjClose();
    }
}

function setObjState()
{
    var width = Math.max(document.documentElement.clientWidth,document.body.clientWidth);
    curSObj.style.left =(width-960)/2+"px";
    curSObj.style.display="block";

    /*
    if(isIe)
    {
    imgObj.style.filter="alpha(opacity=0)";
    }else
    {
    imgObj.style.opacity=0
    }
    curOpacity=0;
    */
}
function setObjOpen()
{
catalogs=document.getElementById("catalog_S");
catalogs.style.display="none";
curSObj.style.overflow="hidden";
divheight-=intHeiStep;
curSObj.style.height= divheight+"px" ;
if (divheight>0)
    setTimeout('setObjOpen()',intTimeStep);
else{
    setObjClose();
    return;
}

/*
if(isIe)
{
    curOpacity+=intAlphaStep;
    imgObj.style.filter="alpha(opacity=" + curOpacity + ")";
    if (curOpacity<100)
        setTimeout('setObjOpen()',intTimeStep);
    else{
        setObjClose();
        return;
    }
}
else{
    curOpacity+=intAlphaStep;
    imgObj.style.opacity =curOpacity;
    if (curOpacity<1) setTimeout('setObjOpen()',intTimeStep);else {setObjClose();return};
}
*/
}
//--------------------
function setObjClose()//
{
    setTimeout('ObjClose()',7000);
}

function Close_Div(){
    catalogs=document.getElementById("catalog_S");
    catalogs.style.display="block";
    curSObj.style.display='none';
    banner_show_num++;
    d_setCookie("showbanner",banner_show_num,"","/","dangdang.com");
}

function ObjClose()
{

divheight-=intHeiStep;
//imgObj.style.filter="alpha(opacity=" + curOpacity + ")";
curSObj.style.overflow="hidden";
if(divheight>0)
curSObj.style.height= divheight+"px" ;
else
    curSObj.style.height='0px';
if (divheight>0) {
setTimeout('ObjClose()',intTimeStep);}else{Close_Div();}

/*
if(isIe)
{
curOpacity-=10;

imgObj.style.filter="alpha(opacity=" + curOpacity + ")";
if (curOpacity>0) {
setTimeout('ObjClose()',50);}else{Close_Div();}
}
else{
curOpacity-=0.1;
if (curOpacity>0) {
imgObj.style.opacity =curOpacity;
setTimeout('ObjClose()',50);}else{Close_Div();}
}
*/
}